using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using AvaloniaWeChatList.ViewModels;

namespace AvaloniaWeChatList.Controls;

public partial class ChatContent : UserControl
{
    public ChatContent()
    {
        InitializeComponent();
        var s = new ChatContentItemModel();
        for (int i = 0; i < 10; i++)
        {
            s.Messages.Add(new MessagesItem());
        }

        this.DataContext = s;
    }

    public ChatContent(string name) : base()
    {
        InitializeComponent();
        var s = new ChatContentItemModel();
        this.DataContext = s;
        Model.Path = BitmapUntil.Load(name);

        s.Messages.Add(new MessagesItem
        {
            Name = "小张",
            Photo = BitmapUntil.Load("1ca35eb545be21611f9b414999cdefac.jpg"),
            Content = "应该可以"
        });
        s.Messages.Add(new MessagesItem
        {
            Name = "我",
            IsSelf = true,
            Photo = BitmapUntil.Load("1ca35eb545be21611f9b414999cdefac.jpg"),
            Content = "可以你脑壳"
        });
        s.Messages.Add(new MessagesItem
        {
            Name = "李亮",
            Photo = BitmapUntil.Load("1ca35eb545be21611f9b414999cdefac.jpg"),
            Content = "大佬这个可以用path这个组件合并起来嘛"
        });
        s.Messages.Add(new MessagesItem
        {
            Name = "我",
            IsSelf = true,
            Photo = BitmapUntil.Load("1ca35eb545be21611f9b414999cdefac.jpg"),
            Content = "不知道你在说什么"
        });
        s.Messages.Add(new MessagesItem
        {
            Name = "毛毛虫",
            Photo = BitmapUntil.Load("1ca35eb545be21611f9b414999cdefac.jpg"),
            Content = "用lunacy"
        });
        s.Messages.Add(new MessagesItem
        {
            Name = "小雪",
            Photo = BitmapUntil.Load("1ca35eb545be21611f9b414999cdefac.jpg"),
            Content = "选中这几个后，在编辑里面有个flatten命令"
        });
        s.Messages.Add(new MessagesItem
        {
            Name = "亮哥",
            Photo = BitmapUntil.Load("1ca35eb545be21611f9b414999cdefac.jpg"),
            Content =
                "还有多久还有多久还有多久还有多久还有多久还有多久还有多久还有多久还有多久还有多久还有多久还有多久还有多久还有多久还有多久还有多久还有多久还有多久还有多久还有多久还有多久还有多久还有多久还有多久还有多久还有多久还有多久还有多久还有多久还有多久还有多久还有多久还有多久"
        });
        s.Messages.Add(new MessagesItem
        {
            Name = "我",
            IsSelf = true,
            Photo = BitmapUntil.Load("1ca35eb545be21611f9b414999cdefac.jpg"),
            Content = "踢了"
        });
    }

    public ChatContentItemModel Model => (ChatContentItemModel)DataContext;
}